package io.gitee.xyuesheng.day04;

import org.junit.Test;

public class TestString {
    @Test
    public void test1() {
        String s = "abc";
        System.out.println(s);
        s += "d";
        System.out.println(s);
    }

    @Test
    public void test2() {
        String s1 = "abc";
        String s2 = "abc";//常量池里面已经有了“abc”，不会重新创建

        String s3 = new String("abc");
        //上面常量池里一个，堆里一个，至此共两个
        String s4 = new String("abc");
        //堆里再加一个，共三个
    }

    @Test
    public void test3() {
        String s1 = "abc";
        String s2 = "abc";
        //创建了一个对象（常量池里面）
    }

    @Test
    public void test4() {
        String s3 = new String("abc");
        String s4 = new String("abc");
        //创建了两个对象，常量池里一个，堆里一个
    }

}
